<?php $pageName="editComment";?> 
<?php require_once('header.php'); ?>    


<div class="repCont brd">
<?php require_once('b_link.php'); ?>  
<?php     
$cId  = Request::getVar('cId'); 
//$cId  = (!isset($cId))? $_POST['cId']:"" ; 

//$action  = (isset($_POST['cAct']))? strtolower($_POST['cAct']):"" ; 

$action  =  trim( Request::getVar('cAct') );
$repId  =   trim(Request::getVar('repId') ); 

$wella = new Base();          
//echo  $action. " helol ".$repId;
       // exit;
if (intval($cId)>0){
      
        
    
        switch($action){
        
        case 'edit':
                
    
           //print_r($from_post);

           $commentObj = $wella->getComment($cId);            
           
           $cTitle = $commentObj[0][1] ;
           $cComment = $commentObj[0][2] ;
           $cRepId = $commentObj[0][3] ;
           $cTitle = $commentObj[0][1] ;
           $cTitle = $commentObj[0][1] ;
           
?>
  <form method="post" id="commentForm" action="editComment.php">
            <fieldset> 
            
            <input type="hidden" id="repId" name="repId" value="<?php echo $cRepId ; ?>" /> 
            <input type="hidden" id="cId" name="cId" value="<?php echo $cId ; ?>" /> 
            <input type="hidden" id="cAct" name="cAct" value="update" /> 
            

                <div class="fItem">
                    <span for="">Editing Comment for Report: <?php echo $cRepId;?></span>
                    
                </div>
                
                <div class="fItem">
                    <label for="cTitle">Comment Title:</label>
                    <input type="text" id="cTitle" name="cTitle"  value="<?php echo $cTitle;?>"/>
                </div>

                <div class="fItem">
                    <label for="cComment">Comment:</label>
                    <textarea id="cComment" name="cComment" class"tArea"><?php echo $cComment;?></textarea>
                </div>

                <div class="fItem actButCont">  
                <div class="rgt">  
                    <input type="button" class="actbutton" id="cDelete" name="cDelete" value="Delete" />
                    <input type="reset" class="actbutton" id="cCancel" name="cCancel" value="Cancel" />
                    <input type="submit" class="actbutton" id="cSubmit" name="cSubmit" value="Update" />
                    
                </div>
                </div>

            </fieldset>

  </form>

<?php
          
        break;
        
   
        case 'update':
            
            $report_id = trim( Request::getVar('repId') );
            $title = trim( Request::getVar('cTitle') );
            $comment = trim( Request::getVar('cComment') );
            
            $wella->saveComment($cId,$title,$report_id,$comment)  ;
        
        break;
        
        case 'delete':
            
            $report_id = trim( Request::getVar('repId') );  
            $wella->deleteComment($cId,$report_id)  ;
        
        break;
        /*default:
            $wella->showFullReport($repId);
        break;     
          */
        
    }
    


?>

<?php 
       
    }else if  ( $action=='addNew' && $repId>0){
     
             
                                                       
?>

  <form method="post" action="editComment.php">
            <fieldset> 
            
            <input type="hidden" id="repId" name="repId" value="<?php echo $repId ; ?>" /> 
            <input type="hidden" id="cId" name="cId" value="" /> 
            <input type="hidden" id="cAct" name="cAct" value="save" /> 
            

                <div class="fItem">
                    <span for="">Adding New Comment for Report: <?php echo $repId ; ?> </span>
                    
                </div>
                
                <div class="fItem">
                    <label for="cTitle">Comment Title:</label>
                    <input type="text" id="cTitle" name="cTitle"  value=""/>
                </div>

                <div class="fItem">
                    <label for="cComment">Comment:</label>
                    <textarea id="cComment" name="cComment" class"tArea"></textarea>
                </div>

                <div class="fItem actButCont">  
                <div class="rgt">  
                      <input type="submit" class="actbutton" id="cSubmit" name="cSubmit" value="Save" />
                </div>
                </div>

            </fieldset>

  </form>

<?php
        // add new comment  
    }else if  ( $action=='save' && $repId>0){

        
            $report_id = trim( Request::getVar('repId') );
            $title = trim( Request::getVar('cTitle') );
            $comment = trim( Request::getVar('cComment') );
            
            $wella->saveComment(0,$title,$report_id,$comment, 'new')  ;
            
        
    }else{
    
    echo "incorrect URI: contact Admin"      ;
    }
?>  

<?php require_once('links.php'); ?>   
  

</div> 




<!--div class="repTitle brd">Title</div>
<div class="repComments brd"></div>
<div class="repImage brd">right</div-->

          


 
 


<?php require_once('footer.php'); ?>   